<?php
/*
* 招标完成验证
*/
class TnoticeBehavior extends Behavior
{
    protected $options   =  array('NOTICE_ON'=>true);

    public function run(&$params=array())
	{
		if($this->options['NOTICE_ON'] && !empty($params['loansn']))
		{
			$map['loansn'] = $params['loansn'];
			$loan = M('Loan')->where($map)->find();
			if(!empty($loan))
			{
				$config = C('TENDER_NOTICE_USER');
				$map['status'] = 1;
				$tendermoney = M('LoanTender')->where($map)->sum('money');
				if($loan['loanmoney']!=$loan['tendermoney'] || $loan['loanmoney']!=$tendermoney)
				{
					$m = explode(',',$config['MOBILE']);
					if(count($m)>0)
					{
						$content = "钱多多标资金有问题，请核实SN={$params['loansn']}";
						import('@.ORG.Util.SMS');
						foreach($m as $mobile)
							SMS::send($mobile,$content);
					}
				}
				$e = explode(',',$config['EMAIL']);
				if(count($e)>0)
				{
					$content = "标题：{$loan['title']}<br/>标总金额：{$loan['loanmoney']}<br/>标招总额：{$loan['tendermoney']}<br/>核算总额：{$tendermoney}";
					import('@.ORG.Util.Mail');
					foreach($e as $email)
						Mail::send($email,'钱多多招标完成',$content);
				}
				return true;
			}
			return false;
		}
		return false;
    }
}

?>